package com.two.commodityorder.controller;
//删除商品
import com.two.commodityorder.service.CommodityService;
import com.two.commodityorder.service.impl.CommodityServiceImpl;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/deleteCommodityServlet.do")
public class DeleteCommodityServlet extends HttpServlet {

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 设置请求对象的编码格式
    	req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
        // 获取传入的商品名称
		String id = req.getParameter("id");
		CommodityService service = new CommodityServiceImpl();
		boolean result = service.DeleteCommodity(id);
		PrintWriter pw = resp.getWriter();
		pw.append(String.valueOf(result));
		pw.flush();
		pw.close();
    }
}